package gwtmodule1.client.gui.salesdept;

import gwtmodule1.client.gui.utils.DekoTable;
import gwtmodule1.client.gui.utils.FrameClient;
import gwtmodule1.client.gui.utils.FrameProvider;
import gwtmodule1.client.gui.utils.SwitchPage;
import gwtmodule1.client.gui.utils.Title;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class PageListRetexForms extends VerticalPanel implements FrameClient {

	private class RetexTable extends DekoTable {

		public RetexTable() {
			super();
			Button add = new Button("add");
			add.addClickListener(new SwitchPage(provider, pageRetexEdit,
					new Integer(0)));
			addTitle("Date");
			addTitle("Customer");
			addTitle("Brand");
			addTitle("Product");
			addTitle("Status");
			addTitleWidget(add);
		}

		public void addItem(int id, String date, String customer, String brand,
				String product, String status) {
			Hyperlink edit = new Hyperlink("edit", "EditRetex" + id);
			edit.addClickListener(new SwitchPage(provider, pageRetexEdit,
					new Integer(id)));
			AddRow r = addRow();
			r.add(date);
			r.add(customer);
			r.add(brand);
			r.add(product);
			r.add(status);
			r.add(edit);
		}
	}

	private Widget createTable() {
		RetexTable table = new RetexTable();
		table.addItem(1, "29/02/06", "Peter Schulze", "Sony", "Playstation",
				"received");
		table.addItem(2, "28/03/06", "Fritz Schulze", "Microsoft", "Xbox",
				"repaired");
		return table;
	}

	private FrameProvider provider;

	private PageRetexEdit pageRetexEdit = new PageRetexEdit();

	public PageListRetexForms(FrameProvider provider) {
		this.provider = provider;
		add(new Title("Return/Exchange Forms"));
		add(createTable());
	}

	public void onShow(Object param) {
	}

}
